<template>
  <div class="banner-box">
    <carousel-3d
        autoplay
        :autoplayTimeout="3000"
        :perspective="0"
        :display="5"
        :animationSpeed="1000"
        :space="400"
        :width="500"
        :height="600"
        controlsVisible
        :controlsHeight="60"
        @before-slide-change="BeforeSlideChange"
    >
      <slide v-for="(item, i) in slides" :index="i" :key="i">
        <div class="swiper-contain" style="">
          <div class="image-contain" :class="activeIndex===i?'curimg':'notcurimg'">
            <img :src="item.src"/>
          </div>
          <div :class="whichside(i)+` ${activeIndex===i?'cur':'notcur'}`" class="text-contain">{{ '0' + (i + 1) }}</div>
        </div>

      </slide>
    </carousel-3d>
  </div>
</template>

<script setup>
/* eslint-disable */
import {ref} from "vue";

const activeIndex = ref(0)
const slides = [
  {
    title: 'parent',
    slide: 23424234234234,
    src: "https://q0.itc.cn/q_70/images03/20240601/8722941d2d3b470cbd13600b0d1fcbdd.png"
  },
  {
    title: 'parent',
    slide: 23424234234234,
    src: "https://img2.baidu.com/it/u=406204377,511607281&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500"
  },
  {
    title: 'parent',
    slide: 23424234234234,
    src: "https://img1.baidu.com/it/u=2866888078,2241363249&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800"
  },
  {
    title: 'parent',
    slide: 23424234234234,
    src: "https://img1.baidu.com/it/u=3022297337,3662978070&fm=253&fmt=auto&app=120&f=JPEG?w=509&h=500"
  },
  {
    title: 'parent',
    slide: 23424234234234,
    src: "https://img2.baidu.com/it/u=868503470,903971783&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500"
  },

]
const imgClick = (data, obj) => {
  console.log(data, obj)
}
const BeforeSlideChange = (v) => {
  activeIndex.value = v
  console.log(v)
}
const whichside = (val) => {
  if (val - activeIndex.value > 0 && Math.abs(val - activeIndex.value) <= 2) {
    return 'right'
  } else if (val - activeIndex.value < 0 && Math.abs(val - activeIndex.value) <= 2) {
    return 'left'
  } else if (val === 0 && activeIndex.value === 4) {
    return 'right'
  } else if ((val === 0 || val === 1) && activeIndex.value === 5) {
    return 'right'
  } else if ((val === 5 || val === 4) && activeIndex.value === 0) {
    return 'left'
  } else if (val === 5 && activeIndex.value === 1) {
    return 'left'
  } else {
    return ''
  }
}
</script>

<style>
.box {
  background: rgb(14, 29, 70);
}

.carousel-3d-container {
  box-sizing: initial !important;
  margin: 0 !important;
  padding: 20px 0 !important;
}


.carousel-3d-slide {
  background-color: initial;
  border-radius: 8px;
  border: 1px solid rgba(61, 83, 117, 0.5);
  box-shadow: 0 20px 20px 3px rgba(30, 132, 246, 0.3);

}

.swiper-contain {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  background-color: rgb(14, 29, 70);
}

.image-contain {
  position: absolute;
  width: 85%;
  height: 100%;
  margin: auto;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 1s;
}

.image-contain {
  margin: 10px;
  width: calc(100% - 20px);
  height: calc((100% - 40px) / 2);
  border-radius: 10px;
  transition: all 1s;
}

.image-contain img {
  width: 100%;
  height: 100%;
}

.text-contain {
  margin: 10px;
  width: calc(100% - 20px);
  height: calc((100% - 40px) / 2);
  border-radius: 10px;
  font-size: 50px;
  font-weight: 600;
  text-align: center;
  color: white;
  transition: all 1s;
}

.left {
  text-align: left;
}

.right {
  text-align: right;
}

.cur {
  top: 10px;
  position: absolute;
  transition: all 1s;
}

.notcur {
  bottom: 10px;
  width: calc(100% - 40px);
  height: calc((100% - 40px) / 4);
  position: absolute;
  transition: all 1s;
}

.curimg {
  bottom: 10px;
  transition: all 1s;
}

.notcurimg {
  top: 50px;
  position: absolute;
  transition: all 1s;
}
</style>